package cn.io1;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class Demo02 {
    public static void main(String[] args) {
        // test11();
        try {
            test12();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private static void test12() throws IOException {
        final FileReader fr = new FileReader("move/mm.log");
        FileWriter fw = new FileWriter("move/mm2.log",true);
        try(fr;fw){
            fw.write("\n");
            char[] chars = new char[1024];
            int len;
            while ((len = fr.read(chars))!=-1){
                fw.write(chars,0,len);
            }
            System.out.println("--success--");
        }catch (IOException e){
            e.printStackTrace();
        }
    }

    private static void test11() {
        try(FileReader reader = new FileReader("move/mm.log")){
            char[] chars = new char[10];
            int len;
            while ((len = reader.read(chars))!=-1){
                System.out.print(new String(chars,0,len));
            }
            System.out.println();
            System.out.println("--ok--");
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
